package com.mcptt.config.body.info.mcdata;

import com.cloudptt.api.product.func.call.CallAttr;
import com.mcptt.config.body.info.mcptt.McpttInfoBody;

import java.io.UnsupportedEncodingException;

public class McdataInfoBody_old extends McpttInfoBody {

	private int callType = CallAttr.CallType_Private;
	private String selfMcpttId = "";
	private int callDir = CallAttr.CallDir_MO;
	private boolean isEmergency = true;
//	private boolean isAlert = true;
	private String funcNum = null;

	public McdataInfoBody_old(int callType, int callDir, String selfMcpttId, boolean isEmergency, String funcNum)
	{
		this.callType = callType;
		this.callDir = callDir;
		this.selfMcpttId = selfMcpttId;
		this.isEmergency = isEmergency;
		this.funcNum = funcNum;
	}

	public String toString()
	{
		StringBuffer strBuff = new StringBuffer();
		strBuff.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append("\r\n");
		strBuff.append("<mcpttinfo xmlns=\"urn:3gpp:ns:mcpttInfo:1.0\">").append("\r\n");
		strBuff.append("<mcptt-Params>").append("\r\n");
		//strBuff.append("<mcptt-request-uri type=\"Normal\">").append("\r\n");
		strBuff.append("<session-type>").append(getCallTypeDesc(callType)).append("</session-type>").append("\r\n");
		//strBuff.append("</ mcptt-request-uri>").append("\r\n");
		if(callDir == CallAttr.CallDir_MT) {
			strBuff.append("<mcptt-called-party-id type=\"Normal\">").append("\r\n");
			strBuff.append("<mcpttURI>").append(selfMcpttId).append("</mcpttURI>").append("\r\n");
			strBuff.append("</mcptt-called-party-id>").append("\r\n");
		}
		if(isEmergency) {
			strBuff.append("<emergency-ind type=\"Normal\">").append("\r\n");
			strBuff.append("<mcpttBoolean>").append(getBooleanDesc(isEmergency)).append("</mcpttBoolean>").append("\r\n");
			strBuff.append("</emergency-ind>").append("\r\n");
		}


		strBuff.append("</mcptt-Params>").append("\r\n");
		strBuff.append("</mcpttinfo>").append("\r\n");

		try {
			return new String(strBuff.toString().getBytes(),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return strBuff.toString();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
